package team.pwy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team.pwy.pojo.entity.Movie;
import team.pwy.pojo.entity.Type;
import team.pwy.service.MovieService;
import team.pwy.service.TypeServer;
import team.pwy.vo.Result;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 本来用来演示:
 *
 * @author feng
 * @date 2023/10/9
 * @Description
 */
@RestController
@RequestMapping("type")
public class TypeController {

    @Autowired
    private TypeServer typeServer;
    @GetMapping("findByType")
    public Result findByType(String type){
        List<Movie> movies=typeServer.findByType(type);
        return new Result("200","查询成功",movies);
    }

    @GetMapping()
    public Result findByMovieId(Integer movieId){
        Type type = typeServer.findByMovieId(movieId);
        return type == null ? new Result("400","查询失败") : new Result("200","查询成功",type);
    }
}
